package com.cssw.fyzb.busi.service.user;

import com.cssw.fyzb.core.dao.user.UserExtDao;
import com.cssw.fyzb.core.model.dodb.UserExt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

@Service
public class UserExtServiceImpl implements UserExtService {

    @Autowired
    UserExtDao userExtDao;

    @Override
    public UserExt findById(Long userId) {
        return userExtDao.get(userId);
    }

    @Override
    public BigDecimal getGzAddPrice(Long userId) {
        UserExt userExt = userExtDao.get(userId);
        if (null == userExt) {
            return BigDecimal.ZERO;
        } else {
            if (null == userExt.getGzAddPrice()) {
                return BigDecimal.ZERO;
            } else {
                return userExt.getGzAddPrice();
            }
        }
    }

    @Override
    public void addGzAddPrice(Long userId, BigDecimal price) {
        userExtDao.addGzAddPrice(userId, price);
    }
}
